//
//  GoOutAcePackCollectionViewCell.m
//  ArtOfLiving
//
//  Created by 刘虎 on 16/5/2.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "GoOutAcePackCollectionViewCell.h"

@interface GoOutAcePackCollectionViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *updateLabel;


@end

@implementation GoOutAcePackCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (void)setModel:(GoOutAcePackTopicModel *)model {
    
    self.typeLabel.text = model.type;
    NSDate *date = [self dateWithString:model.cover_updatetime];
    self.updateLabel.text = [self stringWithDate:date];
    SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/260_390.jpg?cover_updatetime=%@", model.cover, model.cover_updatetime]] placeholderImage:[UIImage imageNamed:@"travelPlaceholder.png"] options:options];
//    http://static.qyer.com/upload/Guide_Info/19/ca/36/260_390.jpg?cover_updatetime=1460110637
}

#pragma mark  - 时间字符串相互转换

- (NSString *)stringWithDate:(NSDate *)date {
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YY.MM.dd"];
    NSString *timeStr = [dateFormatter stringFromDate:date];
    return timeStr;
}

- (NSDate *)dateWithString:(NSString *)string {
    
    NSInteger timeInterval = string.integerValue;
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:timeInterval];
    return date;
}

@end
